From 063a3e96e2f941c106bf629550c08acbd92302af Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 17 Jan 2009 14:16:18 +0000 Subject: [PATCH] New installed header file containing class and typesystem definitions and * babl/babl-class.h: New installed header file containing class and typesystem definitions and types. * babl/babl.h: Include it. * babl/Makefile.am: Add it. svn path=/trunk/; revision=374 --- ChangeLog | 9 ++++ babl/Makefile.am | 2 + babl/babl-class.h | 115 ++++++++++++++++++++++++++++++++++++++++++++++ babl/babl.h | 78 +------------------------------ 4 files changed, 127 insertions(+), 77 deletions(-) create mode 100644 babl/babl-class.h diff --git a/ChangeLog b/ChangeLog index 7822438..b6119a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2009-01-17 Martin Nordholts + + * babl/babl-class.h: New installed header file containing class + and typesystem definitions and types. + + * babl/babl.h: Include it. + + * babl/Makefile.am: Add it. + 2009-01-17 Martin Nordholts * babl/babl.h: Move up forward declaration of BablList. diff --git a/babl/Makefile.am b/babl/Makefile.am index bf52391..b5b64f0 100644 --- a/babl/Makefile.am +++ b/babl/Makefile.am @@ -34,6 +34,7 @@ c_sources = \ babl-version.c h_sources = \ + babl-class.h \ babl-db.h \ babl-ids.h \ babl-internal.h \ @@ -49,6 +50,7 @@ h_sources = \ library_includedir=$(includedir)/babl-$(BABL_API_VERSION)/babl library_include_HEADERS = \ babl.h \ + babl-class.h \ babl-component.h \ babl-conversion.h \ babl-extension.h \ diff --git a/babl/babl-class.h b/babl/babl-class.h new file mode 100644 index 0000000..b8e11fd --- /dev/null +++ b/babl/babl-class.h @@ -0,0 +1,115 @@ +/* babl - dynamically extendable universal pixel conversion library. + * Copyright (C) 2005-2008, Øyvind Kolås and others. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, see + * . + */ + +#ifndef _BABL_CLASS_H +#define _BABL_CLASS_H + +#ifndef _BABL_H +#error this file is only to be included by babl.h +#endif + + +/* magic number used at the start of all babl objects, used to do + * differentiation in polymorphic functions. (as well as manual + * type check assertions). + */ +#define BABL_MAGIC 0xbab100 + +enum { + BABL_INSTANCE = BABL_MAGIC, + BABL_TYPE, + BABL_TYPE_INTEGER, + BABL_TYPE_FLOAT, + BABL_SAMPLING, + BABL_COMPONENT, + BABL_MODEL, + BABL_FORMAT, + + BABL_CONVERSION, + BABL_CONVERSION_LINEAR, + BABL_CONVERSION_PLANE, + BABL_CONVERSION_PLANAR, + + BABL_FISH, + BABL_FISH_REFERENCE, + BABL_FISH_SIMPLE, + BABL_FISH_PATH, + BABL_IMAGE, + + BABL_EXTENSION, + + BABL_SKY +}; +typedef int BablClassType; + +typedef union _Babl Babl; + +typedef int (*BablEachFunction) (Babl *entry, + void *data); + +/* All Classes in babl have common functionality like the ability + * to be iterated over, common functionality is defined through these + * macros. + */ +#define BABL_CLASS_DECLARE(klass) \ + \ +void babl_##klass##_init (void); \ +void babl_##klass##_destroy (void); \ +Babl * babl_##klass##_id (int id); \ +void babl_##klass##_each (BablEachFunction each_fun, \ + void *user_data) + +/* creates a class that has a specific name connected to it, that + * also allows defining a new instance. These classes share common + * functionality with the non_name classes but have two extra methods, + * the means to lookup by name, as well as to create new named objects + * that later can be looked up. + */ +#define BABL_NAMED_CLASS_DECLARE(klass) \ + \ +BABL_CLASS_DECLARE (klass); \ +Babl * babl_##klass (const char *name); \ +Babl * babl_##klass##_new (void *first_arg, \ + ...) BABL_ARG_NULL_TERMINATED + +/* common header for any item inserted into database, the actual + * implementation of babl-instance is in babl-internal + */ +typedef struct +{ + BablClassType class_type; + int id; /*< a numerical id, look at 'babl-ids.h' for the reserved + ones */ + void *creator; + char *name; /*< the name this type exists under */ +} BablInstance; + +/** + * babl_name: + * + * Return a string decsribing a BablInstance, might work better than + * babl->instance.name when a good human readable name is desired. + * + * Returns: a name describing the instance. + */ +const char * babl_name (const Babl *babl); + +void babl_introspect (Babl *babl); /* introspect a given BablObject */ + + +#endif diff --git a/babl/babl.h b/babl/babl.h index e9c5339..f67a856 100644 --- a/babl/babl.h +++ b/babl/babl.h @@ -34,83 +34,7 @@ typedef struct _BablList BablList; #include "babl-macros.h" #include "babl-main.h" - -/* magic number used at the start of all babl objects, used to do - * differentiation in polymorphic functions. (as well as manual - * type check assertions). - */ -#define BABL_MAGIC 0xbab100 - -enum { - BABL_INSTANCE = BABL_MAGIC, - BABL_TYPE, - BABL_TYPE_INTEGER, - BABL_TYPE_FLOAT, - BABL_SAMPLING, - BABL_COMPONENT, - BABL_MODEL, - BABL_FORMAT, - - BABL_CONVERSION, - BABL_CONVERSION_LINEAR, - BABL_CONVERSION_PLANE, - BABL_CONVERSION_PLANAR, - - BABL_FISH, - BABL_FISH_REFERENCE, - BABL_FISH_SIMPLE, - BABL_FISH_PATH, - BABL_IMAGE, - - BABL_EXTENSION, - - BABL_SKY -}; -typedef int BablClassType; - -typedef union _Babl Babl; - -typedef int (*BablEachFunction) (Babl *entry, - void *data); - -/* All Classes in babl have common functionality like the ability - * to be iterated over, common functionality is defined through these - * macros. - */ -#define BABL_CLASS_DECLARE(klass) \ - \ -void babl_##klass##_init (void); \ -void babl_##klass##_destroy (void); \ -Babl * babl_##klass##_id (int id); \ -void babl_##klass##_each (BablEachFunction each_fun, \ - void *user_data) - -/* creates a class that has a specific name connected to it, that - * also allows defining a new instance. These classes share common - * functionality with the non_name classes but have two extra methods, - * the means to lookup by name, as well as to create new named objects - * that later can be looked up. - */ -#define BABL_NAMED_CLASS_DECLARE(klass) \ - \ -BABL_CLASS_DECLARE (klass); \ -Babl * babl_##klass (const char *name); \ -Babl * babl_##klass##_new (void *first_arg, \ - ...) BABL_ARG_NULL_TERMINATED - - - -/* common header for any item inserted into database, the actual - * implementation of babl-instance is in babl-internal - */ -typedef struct -{ - BablClassType class_type; - int id; /*< a numerical id, look at 'babl-ids.h' for the reserved - ones */ - void *creator; - char *name; /*< the name this type exists under */ -} BablInstance; +#include "babl-class.h" /** * babl_name: -- 2.30.2